package com.dhcc.bpm.modules.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.apache.poi.ss.formula.functions.T;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Description 策略模式，查询导出数据列表
 * @Author xiafayu
 * @Date 2021/3/12 9:15
 **/
@Service
public class FactoryForServiceStrategy {

    @Value("${bpm.expTableList}")
    private String expTableLis;

    @Autowired
    Map<String, IService> map = new ConcurrentHashMap<>(20);

    /**
     * @Description 策略模式实现
     * @Author xiafayu
     * @Date 2021/3/12 9:16
     * @param tableName  表名
     * @return IPage
     * @throws
     **/
    public IPage<T> getStrategy(String tableName, Query query, String expSeq){
        QueryWrapper<T> wrapper = new QueryWrapper<>();
        if(null != map.get(tableName)){
            return  map.get(tableName).page(Condition.getPage(query), wrapper.select("*").eq("exp_seq", expSeq));
        }

        return null;
    }

}